import request from './request'

// 部门相关API接口

export interface Department {
  id: number
  name: string
  description?: string
  created_at?: string
  updated_at?: string
}

export interface DepartmentListResponse {
  items: Department[]
  total: number
  page: number
  size: number
}

/**
 * 获取部门列表
 */
export const getDepartments = (params?: {
  page?: number
  size?: number
  name?: string
}): Promise<DepartmentListResponse> => {
  return request.get('/departments/', { params })
}

/**
 * 创建部门
 */
export const createDepartment = (data: Partial<Department>): Promise<Department> => {
  return request.post('/departments/', data)
}

/**
 * 更新部门
 */
export const updateDepartment = (id: number, data: Partial<Department>): Promise<Department> => {
  return request.put(`/departments/${id}`, data)
}

/**
 * 删除部门
 */
export const deleteDepartment = (id: number): Promise<void> => {
  return request.delete(`/departments/${id}`)
}
